@Mapper
public interface StudentMapper {
    @Select("SELECT * FROM student WHERE name LIKE CONCAT('%', #{name}, '%')")
    List<Student> selectAll(@Param("name") String name);
    
    @Select("SELECT * FROM student WHERE id = #{id}")
    Student selectById(Long id);
    
    @Insert("INSERT INTO student(student_no, name, gender, birthday, class_id, major, phone, email, address, status) " +
            "VALUES(#{studentNo}, #{name}, #{gender}, #{birthday}, #{classId}, #{major}, #{phone}, #{email}, #{address}, #{status})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Student student);
    
    @Update("UPDATE student SET name=#{name}, gender=#{gender}, birthday=#{birthday}, class_id=#{classId}, " +
            "major=#{major}, phone=#{phone}, email=#{email}, address=#{address}, status=#{status} " +
            "WHERE id=#{id}")
    void update(Student student);
    
    @Delete("DELETE FROM student WHERE id=#{id}")
    void delete(Long id);
}